<?php echo $this->Html->script('usuario'); ?>
<?php echo $this->Form->create('Usuario', array('action' => 'index', 'id' => 'formulario')); ?>
<style>
    div input {
        /*        width: 95%;*/
    }
    div img {
        float: right;
    }
</style>
<fieldset>
    <legend>Pesquisa de Usuários</legend>
    <table width="98%" border="0" cellspacing="0" cellpadding="2">

        <tr>
            <td colspan="1" >
                <?php echo $this->Form->input('Pesquisar.NM_AUT', array('type' => 'text', 'label' => 'Nome', 'id' => 'txtNomePesquisa', 'class' => 'campoAlfa', 'size' => "30", 'maxlength' => "120", 'required' => 'false')); ?>
            </td>
            <td width="25%">
                <?php echo $this->Form->input('Pesquisar.CD_LOGIN', array('type' => 'text', 'label' => 'CPF', 'id' => 'txtCPFPesquisa', 'class' => 'campoCPF', 'size' => "20", 'maxlength' => "14", 'required' => 'false')); ?>
            </td>
            <td>
                <?php echo $this->Form->input('Pesquisar.NUM_CNS', array('type' => 'text', 'label' => 'CNS', 'id' => 'NUM_CNS', 'class' => 'campoAlfa', 'size' => "30", 'maxlength' => "120", 'required' => 'false')); ?>
            </td>
            <td width="25%">
                <?php echo $this->Form->input('Pesquisar.STATUS', array('type' => 'select', 'label' => 'Status', 'id' => 'txtStatusPesquisa', 'options' => array(null => '', 'A' => 'Ativo', 'I' => 'Inativo'))); ?>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <?php echo $this->Form->input('Pesquisar.CO_PERFIL', array('type' => 'text', 'label' => 'Perfis', 'id' => 'CO_PERFIL', 'class' => 'campoEmail', 'size' => "30", 'maxlength' => "120", 'required' => 'false')); ?>
            </td>
            <td colspan="2">
                <?php echo $this->Form->input('Pesquisar.CO_UNIDADE', array('type' => 'text', 'label' => 'Undiades', 'id' => 'CO_UNIDADE', 'class' => 'campoEmail', 'size' => "30", 'maxlength' => "120", 'required' => 'false')); ?>
                <?php //echo $this->Html->image('/img/ico_perfil.gif') ?>
            </td>
        </tr>
        <tr>
            <td colspan="3"></td>
            <td>
                <input type="submit" id="bntPesquisar" value="Pesquisar" />
            </td>
        </tr>
    </table>
</fieldset>
<?php echo $this->Form->end(); ?>
<br/>
<br/>
<div id="tabelaPesquisa">

    <table id="tbResuldado" class="dataTable">
        <thead>
            <th></th>
        </thead>
        <tbody>
            <?php if (isset($usuarios)) : ?>
                <?php foreach ($usuarios as $u) : ?>
                    <tr>
                        <td>
                            <div style="width: 100%">
                                <div style="width: 10%;float: left;clear: right;">
                                    <a href="usuarios/cadastro/<?php echo h($u['Usuario']['CD_LOGIN']); ?>">
                                        <?php
                                        if (!empty($u['Usuario']['IM_FOTO'])) {
                                            $this->Siscel->foto($u['Usuario']['IM_FOTO'], 70, 70);
                                        } else {
                                            echo $this->Html->image('/img/perfil.jpg', array('width' => '70', 'height' => '70', 'label' => null, 'style' => 'border: 0;margin: 4px 8px;'));
                                        }
                                        ?>
                                    </a>
                                </div>
                                <div style="width: 90%;float: left;">
                                    <div style="float: left;clear: right;width: 100%;">
                                        <table style="width: 100%;border: 0;" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td>Nome: <a href="usuarios/cadastro/<?php echo $u['Usuario']['CD_LOGIN'] ?>"><?php echo $u['Usuario']['NM_AUT'] ?></a></td>
                                                <td>CPF: <?php echo $u['Usuario']['CD_LOGIN'] ?></td>
                                                <td>CNS: <?php ?></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div style="float: left;clear: right;width: 100%;">
                                        <table style="width: 100%;border: 0;" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td>Perfil:
                                                    <?php
                                                    if (1 === $u['Usuario']['TP_AUTORIZADO']) {
                                                        echo 'Usuario';
                                                    } elseif (2 === $u['Usuario']['TP_AUTORIZADO']) {
                                                        echo 'Médico';
                                                    } else {
                                                        echo 'Paciente';
                                                    }
                                                    ?>
                                                </td>
                                                <td style="text-align: right;" colspan="2">
                                                    <?php echo $this->Html->image('/img/bt_ok.gif', array('title' => 'Ativar', 'onclick' => "javascript:executacao('{$u['Usuario']['CD_LOGIN']}', 'ativar')")); ?>
                                                    <?php echo $this->Html->image('/img/excluir.gif', array('title' => 'Excluir', 'onclick' => "javascript:executacao('{$u['Usuario']['CD_LOGIN']}', 'excluir')")); ?>
                                                    <?php echo $this->Html->image('/img/bt_bloquear.gif', array('title' => 'Bloquear', 'onclick' => "javascript:executacao('{$u['Usuario']['CD_LOGIN']}', 'bloquear')")); ?>
                                                    <?php echo $this->Html->image('/img/bt_descredenciar.gif', array('title' => 'Descredenciar', 'onclick' => "javascript:executacao('{$u['Usuario']['CD_LOGIN']}', 'descredenciar')")); ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php endif; ?>
        </tbody>
    </table>
</div>